/*
 * @Author: your name
 * @Date: 2022-03-17 13:38:32
 * @LastEditTime: 2022-03-28 18:31:03
 * @LastEditors: Please set LastEditors
 * @FilePath: \VUE\app\src\store\home\index.js
 */

import { reqGetRegisterCode } from "@/api";

//仓库存储数据的
const state = {
    registerCode:''
};
//修改state的唯一手段
const mutations = {
    GETREGISTERCODE(state,registerCode){
        console.log(registerCode);
        state.registerCode = registerCode
    }
};
//处理action，书写业务逻辑，异步处理
const actions = {
    async getRegisterCode({ commit },phone){
        let result = await reqGetRegisterCode(phone)
        if(result.code == 200){
            commit('GETREGISTERCODE',result.data)
            return 'ok'
        }else {
            return Promise.reject(new Error('faile'))
        }
    }
};

//getters理解为计算属性让组件获取仓库数据更方便
const getters = {};



//暴露一个store实例
export default {
    state,
    mutations,
    actions,
    getters

}
